package by.yativem.commons.task;

import org.apache.log4j.Logger;

 public abstract class MangetTaskCommand extends AbstractCallableTaskCommand<String, AbstractManagedTask> {
	private static final Logger log = Logger.getLogger(MangetTaskCommand.class);
	

	
	public static MangetTaskCommand getCancelTaskCommand() {
		return new MangetTaskCommand() {
			/**
			 * 
			 */
			private static final long serialVersionUID = 1L;

			@Override
			protected String doCommand() throws Exception {
				setResult(  "Cancelled" );
				task.cancelTask();
				return"";
			}
		};
	}

	public static MangetTaskCommand getPausedTaskCommand() {
		return new MangetTaskCommand() {

			@Override
			protected String doCommand() throws Exception {
				setResult("Task paused");
			notifyAllLockedThreads();
			task.pauseTask();
				
				return null;
			}
		};
	}

	protected static final class ContinueTaskCommand extends
	MangetTaskCommand{

		@Override
		protected String doCommand() throws Exception {
			setResult("Task continue");
			task.continueTask();
			return null;
		}
	};

	public static MangetTaskCommand getContinueTaskCommand() {
		return new ContinueTaskCommand();
	}
}
